package com.cssy.xxkj.logic.service;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.byd.acegiext.domain.User;
import com.cssy.base.service.IBaseService;
import com.cssy.xxkj.logic.entity.LogicWarehouseDetailsDO;
import com.cssy.xxkj.logic.entity.LogicWarehouseInventoryDO;
import com.plat.exception.SyBaseException;
import com.plat.helper.SearchConditions;
import com.plat.helper.SearchResult;

public interface ILogicWarehouseInventoryService extends IBaseService<LogicWarehouseInventoryDO> {
	
	/**
	 * 更改库存
	 * @param t 存储有单据信息、物料信息及出入库数量的对象. 必填项 WhCode，Status，Jquantity，Batch
	 * @param user 包含当前登录用户信息的对象
	 * @return
	 */
	@Transactional(propagation=Propagation.REQUIRED)//REQUIRED:业务方法需要在一个容器里运行。如果方法运行时，已经处在一个事务中，那么加入到这个事务，否则自己新建一个新的事务。
	public boolean updateWhAffstockQuantity(LogicWarehouseDetailsDO t, User user ,boolean isUpdateCost)
			throws SyBaseException;
	
	/**
	 * 列表显示库存信息
	 * @param scs
	 * @return
	 * @throws SyBaseException
	 */
	@Transactional
	public SearchResult findForWareHouseStockByExample(SearchConditions scs)
			throws SyBaseException;
	
	/**
	 * 验证库存是否足够用于出库
	 * @param maCode 物料编码
	 * @param whCode 仓库编码 
	 * @param hubCode 仓位编码(无仓位参数定义为空)
	 * @param status 物料状态
	 * @param batch  批次(无批次参数定义为空)
	 * @param quaitity 本次出库数量
	 * @return
	 */
	@Transactional
	public boolean validateStorageQuaitity(String maCode, String whCode,
			String hubCode, String status, String batch, BigDecimal quantity)
			throws SyBaseException;
	@Transactional
	public BigDecimal getStorageQuaitity(String maCode, String whCode,
			String hubCode, String status, String batch)
			throws SyBaseException;
	
	@Transactional
	public Map<String, BigDecimal> getStorageQuaitityToMap(String piCode, 
			String whCode, String hubCode, String batch)
			throws SyBaseException;
	/**
	 * 导出库存列表Excel
	 * @param scs
	 * @param response
	 * @param isShowMoney
	 * @throws SyBaseException
	 */
	public void exportExcel(SearchConditions scs, HttpServletResponse response, boolean isShowMoney)
			throws SyBaseException;

	/**
	 * 查询批次
	 * @param map
	 * @return
	 * @throws SyBaseException
	 */
	public List<String> findbatch(Map map)throws SyBaseException;
	
	public List<LogicWarehouseInventoryDO> findMaterialsByBatchAll(Map<String, Object> map)
			throws SyBaseException;

	public List<LogicWarehouseInventoryDO> findMaterialsBySearchBatch(SearchConditions scs)
			throws SyBaseException;
	
	public List<LogicWarehouseInventoryDO> findWareHouseStockByMap(Map<String, Object> paramMap)throws SyBaseException;
	
	public SearchResult findSingleStockToBackSel(SearchConditions scs)throws SyBaseException;
	
	@Transactional
	public Integer deleteWarehouseInventoryByMap(Map<String, Object> paramMap)throws SyBaseException;

}
